<%@ page import="cn.edu.njust.service.UserService" %>
<%@ page import="cn.edu.njust.service.impl.UserServiceImpl" %>
<%@ page import="cn.edu.njust.pojo.User" %>
<%@ page import="java.util.List" %>
<%@ page import="cn.edu.njust.service.reService" %>
<%@ page import="cn.edu.njust.service.impl.reServiceImpl" %>
<%@ page import="cn.edu.njust.pojo.Register" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>CCF预报名系统|审核资格</title>

  <!-- Google Font: Source Sans Pro -->
  <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,400i,700&display=fallback">
  <!-- Font Awesome -->
  <link rel="stylesheet" href="./plugins/fontawesome-free/css/all.min.css">
  <!-- DataTables -->
  <link rel="stylesheet" href="./plugins/datatables-bs4/css/dataTables.bootstrap4.min.css">
  <link rel="stylesheet" href="./plugins/datatables-responsive/css/responsive.bootstrap4.min.css">
  <link rel="stylesheet" href="./plugins/datatables-buttons/css/buttons.bootstrap4.min.css">
  <!-- Theme style -->
  <link rel="stylesheet" href="./dist/css/adminlte.min.css">

  <script src="./js/axios-0.18.0.js"></script>

</head>
<body class="hold-transition sidebar-mini">
<div class="wrapper">
  <nav class="main-header navbar navbar-expand navbar-white navbar-light">
    <!-- Left navbar links -->
    <ul class="navbar-nav">
      <li class="nav-item">
        <a class="nav-link" data-widget="pushmenu" href="#" role="button"><i class="fas fa-bars"></i></a>
      </li>
    </ul>

    <!-- Right navbar links -->
    <ul class="navbar-nav ml-auto">
      <li class="nav-item">
        <button type="button" class="btn btn-info" onclick="exitRegister()">退出当前登录</button>
      </li>
      <li class="nav-item">
        <a class="nav-link" data-widget="fullscreen" href="#" role="button">
          <i class="fas fa-expand-arrows-alt"></i>
        </a>
      </li>
    </ul>
  </nav>
  <!-- /.navbar -->

  <!-- Main Sidebar Container -->
  <aside class="main-sidebar sidebar-dark-primary elevation-4">
    <!-- Brand Logo -->
    <a href="#" class="brand-link">
      <img src="./dist/img/AdminLTELogo.png" alt="CCF预报名系统" class="brand-image img-circle elevation-3" style="opacity: .8">
      <span class="brand-text font-weight-light">CCF预报名系统</span>
    </a>

    <!-- Sidebar -->
    <div class="sidebar">
      <!-- Sidebar Menu -->
      <nav class="mt-2">
        <ul class="nav nav-pills nav-sidebar flex-column" data-widget="treeview" role="menu" data-accordion="false">
          <!-- Add icons to the links using the .nav-icon class
               with font-awesome or any other icon font library -->
          <li class="nav-item">
            <a href="/CCF_Pre_Registration_System/teacherInfo.jsp" class="nav-link">
              <i class="nav-icon fas fa-eraser"></i>
              <p>我的信息</p>
            </a>
          </li>
          <li class="nav-item">
            <a href="/CCF_Pre_Registration_System/teacherChangeInfo.jsp" class="nav-link">
              <i class="nav-icon fas fa-exclamation"></i>
              <p>修改信息</p>
            </a>
          </li>
          <li class="nav-item">
            <a href="/CCF_Pre_Registration_System/application.jsp" class="nav-link">
              <i class="nav-icon fas fa-exclamation"></i>
              <p>报名情况</p>
            </a>
          </li>
          <li class="nav-item">
            <a href="/CCF_Pre_Registration_System/uploading.jsp" class="nav-link">
              <i class="nav-icon fas fa-exclamation"></i>
              <p>上传名单</p>
            </a>
          </li>
          <li class="nav-item">
            <a href="/CCF_Pre_Registration_System/check.jsp" class="nav-link">
              <i class="nav-icon fas fa-exclamation"></i>
              <p>审核资格</p>
            </a>
          </li>
        </ul>
      </nav>
      <!-- /.sidebar-menu -->
    </div>
    <!-- /.sidebar -->
  </aside>
  <!-- Content Wrapper. Contains page content -->
  <div class="content-wrapper">
    <!-- Main content -->
    <section class="content">
      <div class="container-fluid">
        <div class="row">
          <div class="col-12">
            <div class="card">
              <div class="card-body">
                <form action="#" method="POST" class="form-inline" role="form">
                  <div class="form-group">
                    <select id="grade" class="form-control">
                      <option>选择年级</option>
                      <option>2020</option>
                      <option>2021</option>
                      <option>2022</option>
                      <option>2019</option>
                    </select>
                  </div>
                  <div class="form-group">
                    <select id="major" class="form-control">
                      <option>选择专业</option>
                      <option>计算机类</option>
                      <option>电子信息</option>
                      <option>机械</option>
                    </select>
                  </div>
                  <div class="form-group">
                    <button type="button" class="btn btn-info">查询</button>
                  </div>
                </form>
              </div>
            </div>
            <div class="card">
              <div class="card-body">
                <table id="example1" class="table table-bordered table-hover">
                  <%
                    reService us = new reServiceImpl();
                    List<Register> res = us.selectAllRe();
                  %>
                  <thead>
                  <tr>
                    <th>复选框</th>
                    <th>学号</th>
                    <th>年级</th>
                    <th>专业</th>
                    <th>编程语言</th>
                    <th>自费/免费</th>
                    <th><button type="button" class="btn btn-info">一键批准</button></th>
                    <th><button type="button" class="btn btn-danger">一键否决</button></th>
                  </tr>
                  </thead>
                  <tbody>
                    <%
                       for(int i = 0; i < res.size(); i++) {
                            Register re = res.get(i);
                    %>
                  <tr>
                    <%
                      UserService us1 = new UserServiceImpl();
                      User u2 = us1.selectId01(re.getIdNo());
                    %>
                    <td><input type="checkbox"></td>
                    <td><%=re.getIdNo()%></td>
                    <td>kong</td>
<%--                    <%=u2.getGrade()%>--%>
                    <td>kong</td>
<%--                    <%=u2.getMajor()%>--%>
                    <td><%=re.getLanguage()%></td>
                    <td>
                      <%
                        String ss;
                        if(re.getIsUse()){
                          ss = "免费";
                        }else{
                          ss = "自费";
                        }

                      %>
                      <%=ss%>
                    </td>
                    <td><button type="button" class="btn btn-info" onclick="approve01(<%=re.getIdNo()%>)">批准</button></td>
                    <td><button type="button" class="btn btn-danger" onclick="disapprove01(<%=re.getIdNo()%>)">否决</button></td>
                  </tr>
                      <%
                       }
                      %>
                  <tfoot>
                  <tr>
                    <th>复选框</th>
                    <th>学号</th>
                    <th>年级</th>
                    <th>专业</th>
                    <th>编程语言</th>
                    <th>自费/免费</th>
                    <th><button type="button" class="btn btn-info">一键批准</button></th>
                    <th><button type="button" class="btn btn-danger">一键否决</button></th>
                  </tr>
                  </tfoot>
                </table>
              </div>
            </div>
          </div>
          <!-- /.col -->
        </div>
        <!-- /.row -->
      </div><!-- /.container-fluid -->
    </section>
    <!-- /.content -->
  </div>
  <!-- /.content-wrapper -->
  <footer class="main-footer">
    <div class="float-right d-none d-sm-block">
      <b>Version</b> 1.0.0
    </div>
    <div class="container">
      <div class="row">
        <div class="col-md-offset-1">
          <strong>Copyright &copy; 2022 <a href="#">软件项目管理第六小组</a>.</strong> All rights reserved.
        </div>
      </div>
    </div>
  </footer>

  <!-- Control Sidebar -->
  <aside class="control-sidebar control-sidebar-dark">
    <!-- Control sidebar content goes here -->
  </aside>
  <!-- /.control-sidebar -->
</div>
<!-- jQuery -->
<script src="./plugins/jquery/jquery.min.js"></script>
<!-- Bootstrap 4 -->
<script src="./plugins/bootstrap/js/bootstrap.bundle.min.js"></script>
<!-- AdminLTE App -->
<script src="./dist/js/adminlte.min.js"></script>
<!-- FLOT CHARTS -->
<script src="./plugins/flot/jquery.flot.js"></script>
<!-- FLOT RESIZE PLUGIN - allows the chart to redraw when the window is resized -->
<script src="./plugins/flot/plugins/jquery.flot.resize.js"></script>
<!-- FLOT PIE PLUGIN - also used to draw donut charts -->
<script src="./plugins/flot/plugins/jquery.flot.pie.js"></script>
<!-- AdminLTE for demo purposes -->
<script src="./dist/js/demo.js"></script>
<!-- DataTables  & Plugins -->
<script src="./plugins/datatables/jquery.dataTables.min.js"></script>
<script src="./plugins/datatables-bs4/js/dataTables.bootstrap4.min.js"></script>
<script src="./plugins/datatables-responsive/js/dataTables.responsive.min.js"></script>
<script src="./plugins/datatables-responsive/js/responsive.bootstrap4.min.js"></script>
<script src="./plugins/datatables-buttons/js/dataTables.buttons.min.js"></script>
<script src="./plugins/datatables-buttons/js/buttons.bootstrap4.min.js"></script>
<script src="./plugins/jszip/jszip.min.js"></script>
<script src="./plugins/pdfmake/pdfmake.min.js"></script>
<script src="./plugins/pdfmake/vfs_fonts.js"></script>
<script src="./plugins/datatables-buttons/js/buttons.html5.min.js"></script>
<script src="./plugins/datatables-buttons/js/buttons.print.min.js"></script>
<script src="./plugins/datatables-buttons/js/buttons.colVis.min.js"></script>
<script>
  function approve01(id) {
    axios({
      method: "post",
      url: "/CCF_Pre_Registration_System/shenpi/approveById?id="+ id
    }).then(function (resp) {
      if (resp.data === "success") {
        alert("审批成功");
        window.location.href = "/CCF_Pre_Registration_System/check.jsp"
      } else {
        alert("请重试")
      }
    })
  }
  function disapprove01(id) {
    axios({
      method: "post",
      url: "/CCF_Pre_Registration_System/shenpi/resetById?id="+ id
    }).then(function (resp) {
      if (resp.data === "success") {
        alert("拒绝成功");
        window.location.href = "/CCF_Pre_Registration_System/check.jsp"
      } else {
        alert("请重试")
      }
    })
  }
  $(function () {
    $("#example1").DataTable({
      "responsive": true, "lengthChange": false, "autoWidth": false,
      "buttons": ["copy", "csv", "excel", "pdf", "print", "colvis"]
    }).buttons().container().appendTo('#example1_wrapper .col-md-6:eq(0)');
    $('#example2').DataTable({
      "paging": true,
      "lengthChange": false,
      "searching": false,
      "ordering": true,
      "info": true,
      "autoWidth": false,
      "responsive": true,
    });
  });
  function exitRegister(){
    axios({
      method:"post",
      url:"/CCF_Pre_Registration_System/systemControl/exitCurrentLoginUser"
    }).then(function (resp){
      if(resp.data==="success"){
        window.location.href="index.jsp";
      }else {
        alert("请重试");
      }
    })
  }
</script>
</body>
</html>